from flask import request, session
from flask_restful import Resource
from database import Database

# 创建数据库连接



# Mock user database

class DeleteArticle(Resource):
    def post(self):
        db = Database()
        type = session.get('type')
        data = request.get_json()
        article_id = data.get('articleId')
        if type == 'manager':
            if article_id:
                db.execute_query("DELETE FROM article WHERE articleId = %s", (article_id,))

                return {"message": "article deleted successfully"}, 200
        else:
            return {"message": "not manager"}, 201  # Changed return status to 409 Conflict
